package cate.game.activity.limitshop.msg;

import cate.game.GameBody;
import cate.game.activity.limitshop.DailyNewLimitShopActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBLimitShopActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@ClientMsg(title = "新限购商城-每日商城-额外奖励领取 请求")
public class LimitShopDailyNewExtraReceiveReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;
    @NoteField("配置ID")
    public int tid;

    @Override
    public MsgConfig conf() {
        return MsgIdBLimitShopActivity.LIMIT_SHOP_DAILY_NEW_EXTRA_RECEIVE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        DailyNewLimitShopActivity gift = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (gift == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        try {
            EcResult<DailyNewLimitShopActivity> r = gift.receiveExtraReward(tid);
            if (!r.ok()) {
                game.notice.message(cc.getRole(), r);
            } else {
                gift.noticeUpdate();
            }
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
